package com.wmh.baseservice.admin.mapper;

import com.wmh.baseservice.admin.entity.AdUserRole;
import com.wmh.baseservice.common.mybatisplus.methods.CommonMapper;
import com.wmh.baseservice.common.mybatisplus.structure.LambdaQueryWrapperX;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author wmh generator
 * @since 2023-02-17
 */
public interface AdUserRoleMapper extends CommonMapper<AdUserRole> {

    default List<Long> getRoleIds(Long adId) {
        return selectList(new LambdaQueryWrapperX<AdUserRole>()
                .eq(AdUserRole::getAdId, adId)
                .select(AdUserRole::getRoleId))
                .stream().map(AdUserRole::getRoleId)
                .collect(Collectors.toList());
    }
}
